﻿namespace Busconeitor.BusinessLayer
{
    using Kernel;
    using System;
    using System.Diagnostics;
    using System.IO;

    public class ParserRules
    {
        #region Atributos

        private FileInfo[] _documents; 
        
        #endregion

        #region Constructores

        #endregion

        #region Propiedades

        #endregion

        #region Metodos

        public bool GenerateIndex(string path)
        {
            try
            {
                // Obtengo los documentos que estan en la carpeta PDF
                _documents = new DirectoryInfo(path).GetFiles("*.pdf");

                var parser = new Parser();
                Debug.WriteLine("Inicio: " + new DateTime());

                foreach (var item in _documents)
                {
                    parser.ParseDocument(item);
                }

                Debug.WriteLine("Fin: " + new DateTime());

                var rule = new DocumentRule();
                rule.UpdateNr();
                rule.UpdateMaxTf();

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        } 
        
        #endregion
    }
}
